<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            height: 2000px;
        }

        div {
            position: absolute;
            left: 0;
            top: 0;
            width: 200px;
            height: 200px;
            background-color: lightblue;
        }
    </style>
</head>

<body>
    <div></div>
    <script>
        var div = document.querySelector('div');
        var x = 0, y = 0;

        // touchstart 把触摸点初始坐标记录下来
        div.addEventListener('touchstart', function (e) {
            //计算出touch触摸点在元素内部的坐标
            x = e.targetTouches[0].pageX - div.offsetLeft;
            y = e.targetTouches[0].pageY - div.offsetTop;
        })

        div.addEventListener('touchmove', function (e) {
            e.preventDefault()
            div.style.left = e.targetTouches[0].pageX - x + 'px';
            div.style.top = e.targetTouches[0].pageY - y + 'px';
        })
    </script>
</body>

</html>